--
-- DESCRIPTION
--
-- @COMPANY **
-- @AUTHOR **
-- @DATE ${date} ${time}
--

---@type BP_Spring_C
local M = UnLua.Class()

-- function M:Initialize(Initializer)
-- end

-- function M:UserConstructionScript()
-- end

function M:ReceiveBeginPlay()
    self.CharacterCheck.OnComponentBeginOverlap:Add(self, self.OnComponentBeginOverlap_CharacterCheck)
    -- 绑定图像播放完成
    self.PaperFlipbook.OnFinishedPlaying:Add(self, self.FlipbookFinishedPlaying)
end

-- function M:ReceiveEndPlay()
-- end

-- function M:ReceiveTick(DeltaSeconds)
-- end

-- function M:ReceiveAnyDamage(Damage, DamageType, InstigatedBy, DamageCauser)
-- end

-- function M:ReceiveActorBeginOverlap(OtherActor)
-- end

-- function M:ReceiveActorEndOverlap(OtherActor)
-- end

-- 角色检测
function M:OnComponentBeginOverlap_CharacterCheck(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, FromSweep, SweepResult)

    local CharacterClass = UE.UClass.Load("/Script/Engine.Blueprint'/TowerClimber/Blueprints/Characters/BP_PlatformChar.BP_PlatformChar_C'")

    local Character = OtherActor:Cast(CharacterClass)
    if Character then
        Character:LaunchCharacter(self:GetActorUpVector() * self.LaunchPower, false, true)
        self.PaperFlipbook:SetLooping(false)
        self.PaperFlipbook:SetFlipbook(self.ActiveFlipbook)
        self.PaperFlipbook:Play()
    end

end

-- 翻书结束
function M:FlipbookFinishedPlaying()
    self.PaperFlipbook:SetFlipbook(self.IdleFlipbook)
end

return M
